package com.guchenbo.study.xml;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.aop.ThrowsAdvice;

import java.lang.reflect.Method;

/**
 * @Author guchenbo
 * @Date 2020/1/1.
 */
public class LogAdvice implements MethodBeforeAdvice, AfterReturningAdvice, ThrowsAdvice {

    @Override
    public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
        System.out.println("after " + method.getName());
    }

    @Override
    public void before(Method method, Object[] args, Object target) throws Throwable {
        System.out.println("before " + method.getName());
    }

    public void afterThrowing(Exception ex) {
        System.out.println("error " + ex);
    }
}
